home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / call32 / bezier / bezier.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-11  |  3.0 KB  |  75 lines

  1. VERSION 2.00
  2. Begin Form frmBezier 
  3.    Caption         =   "Close me to stop the madness!"
  4.    ClientHeight    =   4605
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   8340
  8.    DrawWidth       =   3
  9.    ForeColor       =   &H000000FF&
  10.    Height          =   5010
  11.    Left            =   1035
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   307
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   556
  16.    Top             =   1140
  17.    Width           =   8460
  18. Option Explicit
  19. Declare Function Declare32 Lib "call32.dll" (ByVal Func As String, ByVal Library As String, ByVal Args As String) As Long
  20. Declare Sub FreeCall32IDs Lib "call32.dll" ()
  21. Declare Function GetDC Lib "call32.dll" Alias "Call32" (ByVal hwnd As Long, ByVal id As Long) As Long
  22. Declare Function ReleaseDC Lib "call32.dll" Alias "Call32" (ByVal hwnd As Long, ByVal hdc As Long, ByVal id As Long) As Long
  23. Declare Function PolyBezier Lib "call32.dll" Alias "Call32" (ByVal hdc As Long, points As tagPoint, ByVal count As Long, ByVal id As Long) As Long
  24. Declare Function GetDesktopWindow Lib "call32.dll" Alias "Call32" (ByVal id As Long) As Long
  25. Declare Function CreatePen Lib "call32.dll" Alias "call32" (ByVal style As Long, ByVal w As Long, ByVal c As Long, ByVal id As Long) As Long
  26. Declare Function SelectObject Lib "call32.dll" Alias "call32" (ByVal hdc As Long, ByVal hpen As Long, ByVal id As Long) As Long
  27. Declare Function DeleteObject Lib "call32.dll" Alias "call32" (ByVal hpen As Long, ByVal id As Long) As Long
  28. Dim idGetDC As Long
  29. Dim idReleaseDC As Long
  30. Dim idPolyBezier As Long
  31. Dim idCreatePen As Long
  32. Dim idSelectObject As Long
  33. Dim sw As Long, sh As Long
  34. Dim idDeleteObject As Long
  35. Dim h As Long, dc As Long
  36. Dim points() As tagPoint
  37. Const PointCount = 4
  38. Const PS_SOLID = 0
  39. Sub Form_Load ()
  40.     Dim i As Integer, r As Long, hpen As Long
  41.     idGetDC = Declare32("GetDC", "user32", "w")
  42.     idReleaseDC = Declare32("ReleaseDC", "user32", "wi")
  43.     idPolyBezier = Declare32("PolyBezier", "gdi32", "ipi")
  44.     idCreatePen = Declare32("CreatePen", "gdi32", "iii")
  45.     idSelectObject = Declare32("SelectObject", "gdi32", "ii")
  46.     idDeleteObject = Declare32("DeleteObject", "gdi32", "i")
  47.     Show
  48.     dc = GetDC(hwnd, idGetDC)
  49.     ReDim points(PointCount)
  50.     While True
  51.         hpen = CreatePen(PS_SOLID, 5, Rnd * &H1000000, idCreatePen)
  52.         For i = 1 To PointCount
  53.             points(i).x = Rnd * sw
  54.             points(i).y = Rnd * sh
  55.         Next i
  56.         r = SelectObject(dc, hpen, idSelectObject)
  57.         r = PolyBezier(dc, points(1), PointCount, idPolyBezier)
  58.         r = DeleteObject(hpen, idDeleteObject)
  59.         DoEvents
  60.     Wend
  61. End Sub
  62. Sub Form_Resize ()
  63.     sw = ScaleWidth
  64.     sh = ScaleHeight
  65.     Refresh
  66. End Sub
  67. Sub Form_Unload (Cancel As Integer)
  68.     Dim r As Long
  69.     r = ReleaseDC(hwnd, dc, idReleaseDC)
  70.     ' make sure to call this to free the libraries that were loaded by 
  71.     ' Call32.dll - RAL
  72.     Call FreeCall32IDs
  73.     End
  74. End Sub
  75.